<!doctype html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no" />
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../c/aui.css" />
	<style>
		body {
			background-color: transparent;
			background: url('../i/bg.gif');
			outline: 0;
		}

		#loadingdi_huifu-s {
			display: flex;
			width: 100%;
			justify-content: center;
			align-items: center;
			height: 500px;
			text-align: center;
			margin: 0 auto;
			flex-direction: column;
			opacity: 1;
		}

		#loadingdi_huifu-s img {
			width: 2rem;
			height: 2rem;
		}

		#loadingdi_huifu-s div {
			padding-top: 1rem;
			font-size: 0.8rem;
			text-shadow: 1px 2px 5px #fff;
			line-height: 1.5rem;
		}
	</style>
</head>

<body>
	<div id="loadingdi_huifu-s"><img src="../i/footer_progress.png" />
		<!-- <div>出售APP短视频源码<br />微信/电话: 156 2228 9461</div> -->
	</div>
</body>

<script type="text/javascript" src="../j/api.js"></script>
<script type="text/javascript">
	var oxPlayer, di_data, video_index_i, video_index_p, video_index_xh, ad_list_video, _root = 1,
		systemType;
	var list_data = [];
	var video_url_ajax = 'video/lists/limit/10';
	apiready = function() {
		_init_ad();
		systemType = api.systemType;
		video_index_i = video_index_xh = 0;
		video_index_p = 1;
		$api.css($api.byId('loadingdi_huifu-s'), 'height:' + (api.winHeight - 100) + 'px');
		oxPlayer = api.require('oxPlayer');
		// console.log(api.winWidth)
		oxPlayer.addEventListener(function(ret, err) {
				console.log(JSON.stringify(ret));
				switch (ret.code) {
					case 0:
						// 返回
						if (api.winName == 'root') {
							return;
						}
						_close();
						break;
					case 1:
						// 右滑
						break;
					case 2:
						// 单击
						break;
					case 4:
						data_ajax();
						// 滑动到最后一个视频
						break;
					case 5:
						//  播放记录放回index滚动到播放记录索引
						video_index_xh = ret.index;
						// console.log("序号："+ret.value.index)
						di_data = list_data[video_index_xh];
						// console.log(JSON.stringify(ret))

						if(di_data && di_data.ad){
						//	find_ad();
						}
						video_index_i++;
						// console.log(video_index_i);
						// if ((video_index_p * 10) <= video_index_xh) {
						// 	if (_getPrefs('_config').ad.ad) {
						// 		if (_getPrefs('_config').ad.kaiping == 2 && ad_vip) {
						// 			video_index_p++;
						// 			// _url({
						// 			// 	animation: true,
						// 			// 	js: 'kaiping',
						// 			// 	time_jinbi: time_jinbi,
						// 			// 	time_jinbi_name: api.winName,
						// 			// 	time_jinbi_frameName: api.frameName
						// 			// }, 'ad');
						// 		}
						// 	}
						// }
						// console.log(video_index_xh)

						// 判断欢看限制
						setTimeout(function() {
								if (_is_video()) {
									isPlaying();
									_suxiangw_msg();
									return;
								} else if (di_data.money) { // 是否付费观看
									_suxiangw_msg({
										content: '该视频需要付费' + di_data.money + _getPrefs('_config').zhibo.liwu_name,
										rightTitle: '同意付款',
										url: 'fufei()'
									})
									isPlaying();
									return;
								}
							}, 300)
							// 判断结束


				///		增加点击统计
						if (di_data.user) {
							_click(di_data.id);
						} else {
							_ajax('ad/click/id/' + di_data.id)
						}
						_click_member(di_data.id);

						api.execScript({
							frameName: 'time',
							script: 't(' + false + ');'
						});

						break;
					case 6:
						// start开始 pause暂停
						break;
					case 8:
						// 缓冲时返回
						break;
					case 10:
						// alert('放完了')
						_click_member(di_data.id);
						// 播放完成
						break;
					case 99990:
						// 会员头像
						_u(ret.userInfo.uid);
						break;
					case 3:
						console.log(JSON.stringify(ret));
						if (!_getPrefs('_user')) {
							return _login();
						}
						// return;
						// 双击

						var userInfo = ret.userInfo;
						if(userInfo.isLike){
							return;
						}
						userInfo.isLike = true;
						userInfo.likeNum = userInfo.likeNum + 1;
						oxPlayer.updateUserInfo({
							vid: ret.vid,
							userInfo: userInfo
						});
						_zan(ret.vid,'',true);
						_zhen();
						break;
					case 99991:
						// 点赞
						if (!_getPrefs('_user')) {
							return _login();
						}
						// console.log(JSON.stringify(ret))
						var userInfo = ret.userInfo;
						if (ret.isLike == 1) {
							_zhen();
							userInfo.isLike = ret.isLike;
							userInfo.likeNum = userInfo.likeNum+1;
						} else {
							userInfo.isLike = ret.isLike;
							userInfo.likeNum = userInfo.likeNum-1;
						}
						oxPlayer.updateUserInfo({
							vid: ret.vid,
							userInfo: userInfo
						});
						_zan(ret.vid);
						break;
					case 99992:
						// 评论
						_ping(ret.vid, ret.userInfo.commentNum, true);
						break;
					case 99993:
						// 分享
						_fenxiang(di_data);
						break;
					case 99994:
						// 关注按钮
						if (!_getPrefs('_user')) {
							return _login();
						}
						_zhen();
						setTimeout(function(){
							var userInfo = ret.userInfo;
							userInfo.isFocus = true;
							oxPlayer.updateUserInfo({
								vid: di_data.id,
								userInfo: userInfo
							});
							_guanzhu(di_data.uid);
						},systemType == 'ios' ? 0 : 250)
						break;
					case 99995:
						if(!_getPrefs('_user')){
							return _login();
						}
						// 打赏
						// console.log(JSON.stringify(ret))
						_tan({url:'zhibo_view_frm_liwu',_name:'video',vid:ret.vid})
						break;
					case 99996:
						// 同款商品
						console.log(JSON.stringify(di_data))
						if(!_getPrefs('_user')){
							return _login();
						}
						_url({id:di_data.shop_id},'shop_view_win');
						break;
					case 99997:
						// 广告
						console.log(JSON.stringify(di_data))
						_url({url:di_data.ad.url,title:di_data.ad.title},'curl')
					default:
				}
			});
		data_ajax();
		// 回到屏幕
		api.addEventListener({
			name: 'viewappear'
		}, function(ret, err) {
		//	isPlaying(true);
		});
		// 离开屏幕
		api.addEventListener({
			name: 'viewdisappear'
		}, function(ret, err) {
			isPlaying();
		});
		//应用进入后台事件
		api.addEventListener({
			name: 'pause'
		}, function(ret, err) {
			isPlaying();
		});
		// 应用从后台回到前台事件
		api.addEventListener({
			name: 'resume'
		}, function(ret, err) {
			// isPlaying(true);
		});
	};
	var video_url_ajaxs;

	function data_ajax() {
		video_url_ajaxs = video_url_ajax;
		if ((api.pageParam['member']) && api.pageParam['data']) {
			if (di_data) {
				video_url_ajaxs = video_url_ajax + '/suid/' + di_data.uid + '/sid/' + di_data.id
			} else {
				if (api.pageParam['member'] == 'zuopin') {
					video_url_ajaxs = video_url_ajax + '/suid/' + api.pageParam['data']['uid'] + '/sid/' + api.pageParam['data']['id'];
				} else if (api.pageParam['member'] == 'xihuan') {
					video_url_ajaxs = video_url_ajax + '/xihuan/1/suid/' + api.pageParam['data']['xihuan_uid'] + '/sid/' + api.pageParam['data']['xihuan_id'];
				} else if (api.pageParam['member'] == 'shoucang') {
					video_url_ajaxs = video_url_ajax + '/xihuan/2/suid/' + api.pageParam['data']['shoucang_uid'] + '/sid/' + api.pageParam['data']['shoucang_id'];
				} else {
					// video_url_ajaxs = video_url_ajax + '/order/click/';
				}
			}
		}
		// console.log(JSON.stringify(api.pageParam));
		// console.log(video_url_ajaxs);
		// return;
		//	console.log("video_url_ajaxs:" + video_url_ajaxs);
		_ajax(video_url_ajaxs, function(ret, err) {
			if (ret) {
				var data = [];
				if(video_index_i){
					ret = ret.data;
					// _msg('已添加新数据')
					if (ret) {
						for (var i = 0; i < ret.length; i++) {
							data.push(find(ret[i]));
							list_data.push(ret[i]);
						}
					}
					oxPlayer.addDataAfter({styles: find_style(),data:data});
				}else{
					if (api.pageParam['data']) {
						data.push(find(api.pageParam['data']));
						list_data.push(api.pageParam['data']);
					}
					ret = ret.data;
					if (ret) {
						for (var i = 0; i < ret.length; i++) {
							data.push(find(ret[i]));
							list_data.push(ret[i]);
						}
					}

					// console.log(JSON.stringify(data))
					var marginBottom = api.safeArea.bottom;
					if(api.winName == 'root'){
						marginBottom = marginBottom + 56;
					}else{
						marginBottom = marginBottom + 5
					}
					var dbPlay = {
						fixedOn: api.frameName,
						rect: {
							x: 0,
							y: 0,
							w: 'auto',
							h: 'auto'
						},
						fixed: false,
						index: 0,
						event: 'MyClickEvent', //点击事件
						openCache: true,
						rightSlide: false,
						leftSlide:false,
						showBack: api.winName == 'root' ? false : true, //返回按钮是否显示事件返回code:0滑动返回code:1android有效
						showDoubleClick: true, //双击红心点赞事件返回code:3
						playBtn: _i + 'pause_start.png', //中间播放按钮图片(自定义) 可选 没有则用系统自带
						marginBottom: marginBottom, //进度条距离底部距离
						backgroundColor: '#000000',
						backgroundHolder: _i + 'loading_720.png',
						avatarHolder:_i + 'touxiang.png',
						downFresh:false,//下拉刷新开关事件返回code:12
	        	upFresh:false,//上拉拉刷新开关事件返回code:13
						styles: find_style(),
						data: data
					};
					oxPlayer.dbPlay(dbPlay);
					if (api.winName == 'root' && _root == 1 && _getPrefs('_config').ad.ad) {
						setTimeout(function() {
							if (_getPrefs('_config').ad.kaiping == 2 && ad_vip) {
								if (_getPrefs('_config').config.app == 1) {
									return;
								}
								_url({
									animation: true,
									js: 'kaiping',
									time_jinbi_name: api.winName,
									time_jinbi_frameName: api.frameName
								}, 'ad');
							}
						}, 300);
					}
					setTimeout(function(){
						yuandu();
					},2000)
					_root = 0;
					api.execScript({
					    frameName: 'suxiangw_com',
					    script: 'goumai();'
					});
				}
			}
		})
	}
	function yuandu(){
		api.execScript({
				frameName: 'suxiangw_com',
				script: 'yuandu('+_right_h+');'
		});
	}

	function find(ret) {
		var a = {};
		if(ret.ad){
			a.vid = ret.ad.id;
			a.styles = find_ad(ret);
		}else{
			a.vid = ret.id;
			a.styles = find_style(ret);
		}

		if(ret.ad){
			 a.title = "@广告"+ret.ad.content;
		}else{
			a.title = "@" + ret.user.username +  ret.content;
		}
		var thumb = ret.img;
		if(ret.ad){
			thumb = ret.ad.img;
		}
		a.thumb = _img(thumb, api.winWidth, api.winHeight);
		a.url = _sx_qiniu + (ret.ad ? ret.ad.video : ret.url);

		var b = {};
		b.uid = ret.uid;
		b.userName = ret.user.username;
		b.avatar = ret.user ? (ret.user.img ? _img(ret.user.img, 100, 100) : _i + 'touxiang.png') : _i + 'touxiang.png';
		b.isFocus = ret.member_guanzhu ? true : false;
		b.likeNum = ret.zan_num;
		b.isLike = ret.user_zan ? true : false;
		b.commentNum = ret.ping_num;
		b.shareNum = 0;
		b.musicName = '@'+ret.user.username+'创作的原声';
		a.userInfo = b;

		var b = {};
		b.musicId = ret.uid;
		b.musicName = ret.user.username;
		b.musicIcon = ret.user ? (ret.user.img ? _img(ret.user.img, 100, 100) : _i + 'touxiang.png') : _i + 'touxiang.png';
		a.music = b;

		return a;
	}

	function find_ad(ret) {
		var h = api.winHeight;
		var w = api.winWidth;
 		var y = h - (120 + api.safeArea.bottom);
			component_ad = {
				type:'component',
				x:20,
				y:y,
				w:250,
				h:35,
	      rect:{x:0,y:0,w:45,h:45},radius:20,backgroundColor:'#FE2C55',
				alpha:1,border:1,text:'广告详细',
	      textSize:16,textColor:'#FFFFFF',alignment:0,scroll:false,code:99997,hidden:false
			};
			y = y-150
			title = {
				type: 'title',
				x: systemType=='ios'?20:0,
				y: y,
				w: w-(systemType=='ios'?50:30),
				h: systemType == 'ios' ? 120 : 150,
				textSize: 16,
				textColor: '#FFFFFF',
				hidden: false,
				code:99997
			}; //用户名

				var styles = [title,component_ad];
				return styles;

	}

	function find_style(ret) {

		var h = api.winHeight;
		var w = api.winWidth;
		var music, share, comment, like, avatar, focus, title, userName, musicName, hoverText, component_99995,component_99996 = {};

		var x = w - (systemType == 'ios' ? 50 : 50);
		var y = h - 375 - api.safeArea.bottom;
		y = y - 50;

		if(api.winName != 'root'){
			y = y + 60
		}

		var y_r = 75;
		var w_s = 40;
		var h_s = 40;
		var zan_r = 12;
		var num_ico = systemType == 'ios' ? 35 : 40;
		avatar = {
			type: 'avatar',
			x: x - (zan_r / 2),
			y: y,
			w: w_s + zan_r,
			h: h_s + zan_r,
			pic: '',
			radius: 25,
			border:systemType == 'ios'?1:3,
			borderColor: '#FFFFFF',
			hidden: false,
			code: 99990,
		}; //头像
		var focus_w = systemType == 'ios' ? 33 : 30;
		focus = {
			type: 'focus',
			x: x + (systemType == 'ios' ? 4 : 5),
			y: y + (systemType == 'ios' ? 35 : 35),
			w: focus_w,
			h: focus_w,
			pic: '',
			hidden: false,
			code: 99994,
		}; //关注
		y = y + y_r;
		like = {
			type: 'like',
			x: x - (systemType == 'ios' ? 0 : 5),
			y: y,
			w: w_s + (systemType == 'ios' ? 0 : 10),
			h: h_s + (systemType == 'ios' ? 0 : 10),
			// pic:_i+'zan.png',
			// pic1:_i+'zan-s.png',
			hidden: false,
			code: 99991,
			num: {
				hidden: false,
				textColor: '#FFFFFF',
				textSize: 14,
				// marginTop: systemType == 'ios' ? 10 : 20,
				// marginRight:systemType == 'ios' ? 50 : 16,
				x: x - (systemType == 'ios' ? 0 : 5),
				y: y + num_ico + (systemType == 'ios' ? -5 : +5),
				w: w_s + (systemType == 'ios' ? 0 : 10),
				h: h_s + (systemType == 'ios' ? 0 : 10),
			}
		}; //红心点赞
		y = y + y_r;
		comment = {
			type: 'comment',
			x: x,
			y: y,
			w: w_s,
			h: h_s,
			hidden: false,
			code: 99992,

			num: {
				hidden: false,
				textColor: '#FFFFFF',
				textSize: 14,
				// marginTop: systemType == 'ios' ? 10 : 20,
				// marginRight:systemType == 'ios' ? 50 : 16,
				x: x,
				y: y + num_ico,
				w: w_s,
				h: h_s - (systemType == 'ios' ? 10 : 0),
			}

		}; //评论
		y = y + y_r;
		share = {
			type: 'share',
			x: x,
			y: y,
			w: w_s,
			h: h_s,
			hidden: false,
			code: 99993,
		}; //分享
		// console.log(y)
		y = y + y_r - 10;

		// dashang2.png
		component_99995 = {
			type:'component',
			x:x-5,
			y:y,
			w:w_s+10,
			h:h_s+10,
			pic:_i+'dashang2.png',
      rect:{
				x:0,y:0,w:50,h:50
			},
			 code:99995,
			 hidden:false,
		}; //自定义组件

		music = {
			// type:'music',
			// x:x-25,
			// y:y,
			// w:80,
			// h:80,
			// pic:_i+'logo.png',
			// code:16,
			// hidden:false
		}; //旋转音乐

		if (time_jinbi) {
			_right_h = y;
		}

		userName = {};

		//	用户昵称

		// component = {
		// 	type: 'component',
		// 	x: x,
		// 	y: y,
		// 	w: w - x - y_r,
		// 	h: 30,
		// 	text: '@速翔网络',
		// 	textSize: 16,
		// 	textColor: '#FFFFFF',
		// 	alignment: 1,
		// 	hidden: false,
		// 	code: 99990,
		// }; //自定义组件
		y = h - 200 - api.safeArea.bottom;
		if(api.winName == 'root'){

		}else{
			y = y + 60;
		}
		x = 0;
		w = w - 50
		if (systemType == 'ios') {
			y = y + 20;
			x = x + 15;
			w = w - 30;
		}else{
			y = y+35
		}
		if(ret && ret.shop_id){
			component_99996 = {
				type:'component',
				x:20,
				y:y-40,
				w:140,
				h:35,
	      rect:{x:0,y:0,w:45,h:45},radius:20,backgroundColor:'#FE2C55',
				alpha:1,border:1,text:'同款商品',
	      textSize:16,textColor:'#FFFFFF',alignment:0,scroll:true,code:99996,hidden:false
			};
		}


		//
		// component = {
		// 	type:'component',x:w-300,y:200,w:150,h:40,pic:_i+'logo.png',
    //   rect:{x:0,y:0,w:45,h:45},radius:5,backgroundColor:'#FE2C55',
		// 	alpha:0.8,border:1,borderColor:'#E066FF',text:'同款商品',
    //   textSize:18,textColor:'#C0FF3E',alignment:7,processColor:'#FF0000',
		// 	processValue:0,scroll:true,code:26,hidden:false
		// }; //同款商品
		//视频简介
		title = {
			type: 'title',
			x: x,
			y: y,
			w: w,
			h: systemType == 'ios' ? 120 : 150,
			textSize: 16,
			textColor: '#FFFFFF',
			hidden: false,
			code:99995
		}; //用户名
		musicName = {
			// type: 'musicName',
      //   x: 50,
      //   y: 100,
      //   w: 100,
      //   h: 30,
      //   textSize: 16,
      //   textColor: '#FFFFFF',
      //   code: 23,
      //   hidden: false
		}; //音乐滚动字幕
		hoverText = {}; //评论输入框 pic1 @图标 pic2 发送图标 text 输入框placeholder文字


		var styles = [music, share, comment, like, avatar, focus, title, userName, musicName, hoverText, component_99995,component_99996];
		return styles;
	}
	// 开始播放
	function isPlaying(a) {
		if (!a) {
			oxPlayer.pause();
			api.execScript({
				frameName: 'time',
				script: 't(' + true + ');'
			});
			video_jindu_set = true;
		} else {
			if (_is_video()) {
				return _suxiangw_msg();
			}else if(di_data && di_data.money){
				return _suxiangw_msg({content:'该视频需要付费'+di_data.money+_getPrefs('_config').zhibo.liwu_name,rightTitle:'同意付款',url:'fufei()'})
			}
			oxPlayer.start();
			api.execScript({
				frameName: 'time',
				script: 't(' + false + ');'
			});
			video_jindu_set = false;
		}
	}

	// 付费视频观看
	function fufei() {
		if(!_getPrefs('_user')){
			return _login();
		}
		_loading('正在请求');
		_ajax('member/video_money', function(ret, err) {
			_loadingCloes();
			if (ret) {
				console.log(JSON.stringify(ret))
				if (ret.ret) {
					_suxiangw_msg2({
						rightTitle: '立刻观看视频',
					}, function(ret) {
						if (ret.eventType == 'right') {
							// 付款成功更新视频
							di_data.money = 0;
							data_ajax();
							api.closeFrame({
								name: 'isPlaying'
							});
						}
						dialogBox.close({
							dialogName: 'alert'
						});
					});
				} else {
					_suxiangw_msg({content:ret.err,rightTitle:'立即充值',url:"_url({url: 'zhibo_view_frm_chongzhi',title: '充值'})"})
				}
			}else{
				_alert(JSON.stringify(err))
			}
		}, {
			vid: di_data.id
		})
	}




</script>

</html>
